package com.neusoft.ysu.npms.controller;


import com.neusoft.ysu.npms.pojo.Help;
import com.neusoft.ysu.npms.pojo.Helpman;
import com.neusoft.ysu.npms.pojo.Result;
import com.neusoft.ysu.npms.service.IHelpService;
import com.neusoft.ysu.npms.service.IHelpmanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者：刘金秋
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/helpman")
public class HelpmanController {
    @Autowired
    IHelpmanService helpmanService;

    @RequestMapping("/add")
    public Result add(@RequestBody Helpman helpman) {
//        System.out.println(department);
        helpmanService.add(helpman);
        return Result.success();
    }
    @RequestMapping("/delete")
    public Result deleteHelpman(@RequestBody Helpman helpman) {
//        System.out.println(department);
        helpmanService.deleteHelpman(helpman);
        return Result.success();
    }
    @RequestMapping("/update")
    public Result updateHelpman(@RequestBody Helpman helpman){
        helpmanService.updateHelpman(helpman);
        return Result.success();
    }

    @RequestMapping("/getAll")
    public Result getAll(@RequestBody Helpman helpman, @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                         @RequestParam(value = "pageSize", required = false, defaultValue = "5") int pageSize){
        return Result.success(helpmanService.selectAll(helpman,pageNum,pageSize));
    }

    @RequestMapping("findone")
    public Result findone(@RequestBody Helpman helpman){
        System.out.println(helpman);
        helpmanService.findById(helpman);
        return Result.success();
    }
}
